//只出现一次的数字 II
//测试链接 https://leetcode.cn/problems/single-number-ii/description/
public class SingleNumber {
    public static int singleNumber(int[] nums) {
        int ret = 0;
        for(int i = 0; i < 32; i++){ //每次循环修改ret的每一位
            int sum = 0;
            for(int num : nums){
                if( ((num >> i) & 1) == 1){
                    sum++;
                }
            }
            if(sum%3 == 1){
                ret |= (1 << i);
            }
        }
        return ret;
    }
}
